From a6657b972719a2bf6042b3a3c3c227808e6339f6 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 17 Feb 2005 04:57:18 +0000 Subject: [PATCH] bitkeeper revision 1.1214 (4214242enp-tUaPA2f1ysNS2qvLPHQ) More serial cleanups. Signed-off-by: Keir Fraser --- xen/drivers/char/serial.c | 47 ++++++++++++++++++------------------ xen/include/asm-x86/serial.h | 15 +++--------- xen/include/xen/serial.h | 4 +-- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c index cc6e45a970..2d7855e5fa 100644 --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -18,6 +18,11 @@ #include #include +/* Config serial port with a string ,DPS,,. */ +static unsigned char opt_com1[30] = OPT_COM1_STR, opt_com2[30] = OPT_COM2_STR; +string_param("com1", opt_com1); +string_param("com2", opt_com2); + /* Register offsets */ #define RBR 0x00 /* receive buffer */ #define THR 0x00 /* transmit holding */ @@ -74,16 +79,16 @@ #define RXBUFSZ 32 #define MASK_RXBUF_IDX(_i) ((_i)&(RXBUFSZ-1)) -typedef struct { +struct uart { int baud, data_bits, parity, stop_bits, io_base, irq; serial_rx_fn rx_lo, rx_hi, rx; spinlock_t lock; unsigned char rxbuf[RXBUFSZ]; unsigned int rxbufp, rxbufc; struct irqaction irqaction; -} uart_t; +}; -static uart_t com[2] = { +static struct uart com[2] = { { 0, 0, 0, 0, 0x3f8, 4, NULL, NULL, NULL, SPIN_LOCK_UNLOCKED }, @@ -95,20 +100,12 @@ static uart_t com[2] = { #define UART_ENABLED(_u) ((_u)->baud != 0) #define DISABLE_UART(_u) ((_u)->baud = 0) -/* Architecture-specific private definitions. */ -#include - -/* opt_com[12]: Config serial port with a string ,DPS,,. */ -static unsigned char opt_com1[30] = OPT_COM1_STR, opt_com2[30] = OPT_COM2_STR; -string_param("com1", opt_com1); -string_param("com2", opt_com2); - /*********************** * PRIVATE FUNCTIONS */ -static void uart_rx(uart_t *uart, struct xen_regs *regs) +static void uart_rx(struct uart *uart, struct xen_regs *regs) { unsigned char c; @@ -134,12 +131,14 @@ static void uart_rx(uart_t *uart, struct xen_regs *regs) } } -static void serial_interrupt(int irq, void *dev_id, struct xen_regs *regs) +static void serial_interrupt( + int irq, void *dev_id, struct xen_regs *regs) { - uart_rx((uart_t *)dev_id, regs); + uart_rx((struct uart *)dev_id, regs); } -static inline void __serial_putc(uart_t *uart, int handle, unsigned char c) +static inline void __serial_putc( + struct uart *uart, int handle, unsigned char c) { unsigned long flags; int space; @@ -167,7 +166,7 @@ static inline void __serial_putc(uart_t *uart, int handle, unsigned char c) return; \ } while ( 0 ) -static void parse_port_config(char *conf, uart_t *uart) +static void parse_port_config(char *conf, struct uart *uart) { if ( *conf == '\0' ) return; @@ -233,7 +232,7 @@ static void parse_port_config(char *conf, uart_t *uart) } } -static void uart_config_stage1(uart_t *uart) +static void uart_config_stage1(struct uart *uart) { unsigned char lcr; @@ -258,7 +257,7 @@ static void uart_config_stage1(uart_t *uart) outb(FCR_ENABLE | FCR_CLRX | FCR_CLTX | FCR_TRG14, uart->io_base + FCR); } -static void uart_config_stage2(uart_t *uart) +static void uart_config_stage2(struct uart *uart) { int rc; @@ -348,7 +347,7 @@ int parse_serial_handle(char *conf) void serial_set_rx_handler(int handle, serial_rx_fn fn) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; unsigned long flags; if ( handle == -1 ) @@ -389,7 +388,7 @@ void serial_set_rx_handler(int handle, serial_rx_fn fn) void serial_putc(int handle, unsigned char c) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; if ( handle == -1 ) return; @@ -399,7 +398,7 @@ void serial_putc(int handle, unsigned char c) void serial_puts(int handle, const unsigned char *s) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; if ( handle == -1 ) return; @@ -426,7 +425,7 @@ static int byte_matches(int handle, unsigned char *pc) unsigned char irq_serial_getc(int handle) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; unsigned char c; @@ -451,7 +450,7 @@ unsigned char irq_serial_getc(int handle) unsigned char serial_getc(int handle) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; unsigned char c; unsigned long flags; @@ -476,7 +475,7 @@ unsigned char serial_getc(int handle) void serial_force_unlock(int handle) { - uart_t *uart = &com[handle & SERHND_IDX]; + struct uart *uart = &com[handle & SERHND_IDX]; if ( handle != -1 ) uart->lock = SPIN_LOCK_UNLOCKED; } diff --git a/xen/include/asm-x86/serial.h b/xen/include/asm-x86/serial.h index 3ec4a2e1e9..152a07c4d6 100644 --- a/xen/include/asm-x86/serial.h +++ b/xen/include/asm-x86/serial.h @@ -1,9 +1,4 @@ /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ -/****************************************************************************** - * asm-x86/serial.h - * - * Architecture-specific private serial definitions. - */ #ifndef __ASM_X86_SERIAL_H__ #define __ASM_X86_SERIAL_H__ @@ -11,12 +6,8 @@ #define OPT_COM1_STR "" #define OPT_COM2_STR "" -static inline int arch_serial_putc(uart_t *uart, unsigned char c) -{ - int space; - if ( (space = (inb(uart->io_base + LSR) & LSR_THRE)) ) - outb(c, uart->io_base + THR); - return space; -} +#define arch_serial_putc(_uart, _c) \ + ( (inb((_uart)->io_base + LSR) & LSR_THRE) ? \ + (outb((_c), (_uart)->io_base + THR), 1) : 0 ) #endif /* __ASM_X86_SERIAL_H__ */ diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h index b5f5affdb2..a0e2948e8a 100644 --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -6,9 +6,6 @@ * it permits debugging of seriously-toasted machines (e.g., in situations * where a device driver within a guest OS would be inaccessible). * - * This file contains public definitions. The arch-specific header - * contains only private hooks, and is not included from this file. - * * Copyright (c) 2003-2005, K A Fraser */ @@ -16,6 +13,7 @@ #define __XEN_SERIAL_H__ #include +#include /* 'Serial handles' are comprise the following fields. */ #define SERHND_IDX (1<<0) /* COM1 or COM2? */ -- 2.30.2